package countWords;

import java.util.HashMap;
import java.util.Map;

public class Solution {
    public int countWords(String[] words1, String[] words2) {
        Map<String,Integer> map = new HashMap<>();
        for (String word: words1) {
            map.put(word,map.getOrDefault(word,0)+1);
        }
        int ans = 0;
        for (String word: words2) {
            // 如果在words1里面只出现了一次的
            if(map.getOrDefault(word,0) == 1) {
                ans++;
                map.put(word,100000);
            }else if(map.getOrDefault(word,0) == 100000) {
                ans--;
                map.put(word,1000001);
            }
        }
        return ans;
    }
}
